﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Itegracion.Framework.Forms;
using System.Reflection;

namespace Itegracion.Framework.Model
{
    public class Proxy
    {
        public static List<Element> Invoke(string assembly_name, string type_name, string method_name, List<Element> input, out ProxyCode code)
        {
            //Type type = Type.GetType(string.Format("{0}.Model.{1}", assembly_name, type_name));

            Type type = Assembly.LoadFrom(string.Format("{0}.dll", assembly_name)).GetType(string.Format("{0}.Model.{1}", assembly_name, type_name),true);

            MethodInfo method = type.GetMethod(method_name);

            List<Element> rpta = (List<Element>)method.Invoke(type, new object[] { input });

            code = ProxyCode.Ok;

            return rpta;
        }
    }

    public enum ProxyCode
    {
        Ok, Error
    }
}
